<?php
    $menu_1 = '';
    $menu_2 = '';
    $menu_3 = '';
    $menu_4 = '';
    $menu_5 = '';
    $menu_6 = '';
    $menu_7 = '';
    $menu_8 = ' class="active"';
    include('header.php');
    
    if(isset($_GET['id'])){
	$news_id = $_GET['id'];
    }else{
	$news_id = 0;
    }
    
    $sql = "SELECT * FROM news WHERE news_active=1 ORDER BY news_date DESC";
    $result = $db->Execute($sql);
    $i = 0;
    $news_list = '';
    $news_detail = '';
    while (!$result->EOF)
    {
        $news_date = date('d/m/Y',$result->fields['news_date']);
        $class = '';
	if($result->fields['news_id']==$news_id){
	    $class = ' main_content_left_box_news_current';
	}else if($news_id==0 AND ($i)==0){
	    $class = ' main_content_left_box_news_current';
	}
	
	$news_list .= <<<news_list
	    <div class="main_content_left_box_news{$class}">
		<a href="news.php?id={$result->fields['news_id']}" title="{$result->fields['news_title']}">
		{$news_date} {$result->fields['news_title']}
		</a>
	    </div>
news_list;
	
	if($result->fields['news_id']==$news_id){
	    $msg1 = nl2br(stripslashes($result->fields['news_msg_1']));
	    $msg2 = nl2br(stripslashes($result->fields['news_msg_2']));
	    $location = nl2br($result->fields['news_location']);
	    
	    if($result->fields['news_video']!=''){
		$video_ = explode('/',$result->fields['news_video']);
		$video = '<iframe width="460" height="300" src="http://www.youtube.com/embed/'.end($video_).'" frameborder="0" allowfullscreen></iframe>';
	    }else{
		$video = '';
	    }
	    
	    switch($result->fields['news_video_pos']){
		case 1:
		    $news_detail = '<div class="location">Location : '.$location.'</div><div class="video">'.$video.'</div><div class="msg">'.$msg1.'</div><div class="msg">'.$msg2.'</div>';
		    break;
		case 2:
		    $news_detail = '<div class="location">Location : '.$location.'</div><div class="msg">'.$msg1.'</div><div class="video">'.$video.'</div><div class="msg">'.$msg2.'</div>';
		    break;
		case 3:
		    $news_detail = '<div class="location">Location : '.$location.'</div><div class="msg">'.$msg1.'</div><div class="msg">'.$msg2.'</div><div class="video">'.$video.'</div>';
		    break;
	    }
	}else if(($i)==0){
	    $msg1 = nl2br(stripslashes($result->fields['news_msg_1']));
	    $msg2 = nl2br(stripslashes($result->fields['news_msg_2']));
	    $location = nl2br($result->fields['news_location']);
	    
	    if($result->fields['news_video']!=''){
		$video_ = explode('/',$result->fields['news_video']);
		$video = '<iframe width="460" height="300" src="http://www.youtube.com/embed/'.end($video_).'" frameborder="0" allowfullscreen></iframe>';
	    }else{
		$video = '&nbsp;';
	    }
	    
	    switch($result->fields['news_video_pos']){
		case 1:
		    $news_detail = '<div class="location">Location : '.$location.'</div><div class="video">'.$video.'</div><div class="msg">'.$msg1.'</div><div class="msg">'.$msg2.'</div>';
		    break;
		case 2:
		    $news_detail = '<div class="location">Location : '.$location.'</div><div class="msg">'.$msg1.'</div><div class="video">'.$video.'</div><div class="msg">'.$msg2.'</div>';
		    break;
		case 3:
		    $news_detail = '<div class="location">Location : '.$location.'</div><div class="msg">'.$msg1.'</div><div class="msg">'.$msg2.'</div><div class="video">'.$video.'</div>';
		    break;
	    }
	}
	$i++;
        $result->MoveNext();
    }
    $result->Close();
?>
	    <div id="main_content">
		
		<div class="page_title" id="news_title">
		    <img src="images/news_title.jpg" alt="News" />
		</div>
		
		<div id="news_content_left">
		    <?php echo $news_list; ?>
		</div>
		
		<div id="news_content_right">
		    <div id="news_content_right_">
			<?php echo stripslashes($news_detail); ?>
		    </div>
		</div>
		<div class="clear">&nbsp;</div>
		
	    </div>
<?php
    include('footer.php');
?>